package com.imessage.service.impl;

import com.bean.BusinessApple;
import com.imessage.service.AppleService;
import com.imessage.service.BaseService;
import com.imessage.type.BusinessAppleState;
import io.ebean.Expr;
import io.ebean.Expression;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class AppleServiceImpl implements AppleService {

    @Autowired
    private BaseService baseService;

    @Override
    public BusinessApple findBusinessApple() {
        List<Expression> expressionList=new ArrayList<Expression>();
        expressionList.add(Expr.eq("state", BusinessAppleState.available.getCode()));
        return baseService.findObject(BusinessApple.class,expressionList,null,"random()" );
    }
}
